package com.ling.pl.security.feign;

import com.ling.pl.security.model.DefaultUrlVO;
import com.ling.pl.security.model.UrlComponentVO;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * @author bo.wang
 */
@RequestMapping("/defaultUrl")
@FeignClient(name = "LING-CLOUD-BASE")
public interface DefaultUrlService extends BaseDefaultUrlService {

    @RequestMapping(value = "/refreshUrlCache", method = RequestMethod.GET)
    public void refreshUrlCache();

    @RequestMapping(value = "/loadUrls", method = RequestMethod.GET)
    public Collection<DefaultUrlVO> loadUrls(@RequestParam("parentId") String parentId) throws Exception;

    @RequestMapping(value = "/countChildren", method = RequestMethod.GET)
    public int countChildren(@RequestParam("parentId") String parentId);

    @RequestMapping(value = "/loadUrlsByUrlIdAndroleId", method = RequestMethod.GET)
    public List<UrlComponentVO> loadUrlsByUrlIdAndroleId(@RequestParam("urlId") String urlId, @RequestParam("roleId") String roleId);

    /**
     * 新建UrlComponent关系
     *
     * @param parameter
     * @throws Exception
     */
    @RequestMapping(value = "/insertUrlComponents", method = RequestMethod.POST)
    public void insertUrlComponents(Map<String, Object> parameter) throws Exception;

    /**
     * 从缓存中查询url树结构
     *
     * @param parentId
     * @return
     */
    @RequestMapping(value = "/loadMeunUrlsFromCache", method = RequestMethod.GET)
    public Collection<DefaultUrlVO> loadMeunUrlsFromCache(@RequestParam("parentId") String parentId);

    /**
     * 从缓存中查询子urls
     *
     * @param parentId
     * @return
     */
    @RequestMapping(value = "/loadContainChildMeunUrlsFromCache", method = RequestMethod.GET)
    public Collection<DefaultUrlVO> loadContainChildMeunUrlsFromCache(@RequestParam("parentId") String parentId);

    /**
     * 触发url缓存刷新
     */
    @RequestMapping(value = "/cacheNavigatorUrls", method = RequestMethod.GET)
    public void cacheNavigatorUrls();
}

